package com.movieManager.action;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.sf.json.JSONArray;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;

import com.movieManager.bean.bean_movie;
import com.movieManager.impl.dealMainDAO;
import com.movieManager.interfac.dealMain;

public class action_main extends DispatchAction{

	
	public ActionForward recommend(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) throws Exception {
		// TODO Auto-generated method stub
		System.out.println("test main");
		dealMainDAO deal=new dealMainDAO();
		List<bean_movie> list=deal.getByTimes();
		JSONArray jsonArrayFromList = JSONArray.fromObject(list); 
		System.out.println(jsonArrayFromList);
		response.setContentType("application/json;charset=utf-8");
		response.getWriter().print(jsonArrayFromList);
		return null;
	}

	public ActionForward recommend1(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) throws Exception {
		// TODO Auto-generated method stub
		//System.out.println("test main");
		dealMainDAO deal=new dealMainDAO();
		List<bean_movie> list=deal.getByTime();
		JSONArray jsonArrayFromList = JSONArray.fromObject(list); 
		System.out.println(jsonArrayFromList);
		response.setContentType("application/json;charset=utf-8");
		response.getWriter().print(jsonArrayFromList);
		return null;
	}

}
